/* test_symbol.cpp */

#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <boost/assign/list_of.hpp>
#include <dodo_plot/dodo_plot.h>
#include <dodo_plot/symbol/plus_symbol.h>
#include <dodo_plot/symbol/arrow_symbol.h>
#include <dodo_plot/widget/vector_field.h>

using namespace std;
using namespace boost::assign;
using namespace dodo_plot;
using namespace dodo_plot::color_name;

Arrow_Symbol point_to_arrow(const Point& p)
{
	//using atan2(x, y) because we take north as 0 degrees. 
	return Arrow_Symbol(
		std::atan2(p.x, p.y) * 180 / 3.14159265,
		std::sqrt(p.x * p.x + p.y * p.y)
		);
}

Point null_point_conv(double x, double y)
{
	return Point(x, y);
}

int main(int argc, char *argv[])
{
	Arrow_Symbol arrow(45, 20, 5, 0.5, GREEN);
	
	vector<double> x = list_of(10)(20)(30);
	vector<double> y = list_of(10)(30)(20);
	vector<Point> wind = list_of(Point(30, 20))(Point(0, 50))(Point(260, 0));
	
	Vector_Field<Arrow_Symbol> field(
		wind.begin(), wind.end(), x.begin(), y.begin(),
		0, 50, 
		0, 40,
		point_to_arrow,
		null_point_conv);

	Blank blank(500, 400);
	Blank bk(300, 200, color_name::PURPLE, true, color_name::GREEN, 5);
	Picture final = blank + bk + frame(field, 300, 200, true);

	Canvas canvas(500, 400);
	canvas.draw(final);
	canvas.write_png("symbol.png");

	return 0;
}

